//
//  LMStatusTool.m
//  李明微博
//
//  Created by 张青花 on 15/12/13.
//  Copyright (c) 2015年 李明. All rights reserved.
//

#import "LMStatusTool.h"
#import "LMHttpTool.h"
#import "LMAccount.h"
#import "MJExtension.h"

#import "LMStatusParam.h"
#import "LMStatusResult.h"
#import "LMHttpTool.h"

@implementation LMStatusTool

+ (void)newStatusWithSinceId:(NSString *)sinceId  success:(void (^)(NSArray *status))success
                     failure:(void (^)(NSError *error))failure
{
    LMStatusParam *param = [LMStatusParam param];
    if (sinceId) {
        param.since_id = sinceId;
    }
    [LMHttpTool GET:@"https://api.weibo.com/2/statuses/friends_timeline.json" parameters:param.mj_keyValues success:^(id responseObject) {
        LMStatusResult *result = [LMStatusResult mj_objectWithKeyValues:responseObject];
        
        if (success) {
            success(result.statuses);
        }
        
    } failure:^(NSError *error) {
        
        if (failure) {
            failure(error);
        }
    }];
    
    
}


+ (void)oldStatusWithMaxId:(NSString *)maxId  success:(void (^)(NSArray *status))success
                   failure:(void (^)(NSError *error))failure
{
    LMStatusParam *param = [LMStatusParam param];
    if (maxId) {
        param.max_id = maxId;
    }
    [LMHttpTool GET:@"https://api.weibo.com/2/statuses/friends_timeline.json" parameters:param.mj_keyValues success:^(id responseObject) {
        LMStatusResult *result = [LMStatusResult mj_objectWithKeyValues:responseObject];
        
        if (success) {
            success(result.statuses);
        }
        
    } failure:^(NSError *error) {
        
        if (failure) {
            failure(error);
        }
    }];
}

@end
